package com.wisdytech.linkdcs.equipment.service.impl;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.wisdytech.common.exception.ServiceException;
import com.wisdytech.common.handler.BaseService;
import com.wisdytech.common.utils.BaseUtil;
import com.wisdytech.linkdcs.equipment.dao.IModelOperationDao;
import com.wisdytech.linkdcs.equipment.model.ModelOperation;
import com.wisdytech.linkdcs.equipment.service.IModelOperationService;

@Service
@Transactional
public class ModelOperationServiceImpl extends BaseService<IModelOperationDao, ModelOperation> implements IModelOperationService {

	@Autowired
	private IModelOperationDao iModelOperationDao;
	
	@Override
	public void add(ModelOperation mo) {
		mo.setPkId(BaseUtil.getUUID());
		mo.insert();

	}

	@Override
	public void del(String modelCode) {
		
		if(StringUtils.isBlank(modelCode)) {
			throw new ServiceException("设备类型编码为空！");
		}
		
		EntityWrapper<ModelOperation> ew =new EntityWrapper<>();
		ew.eq("MODEL_CODE", modelCode);
		
		iModelOperationDao.delete(ew);

	}

	@Override
	public void add(List<ModelOperation> mos) {
		for(ModelOperation mo : mos ) {
			add(mo);
		}
		
	}

	@Override
	public List<ModelOperation> listOperations(String modelCode) {
		
		return iModelOperationDao.listOperations(modelCode);
	}

}
